package com.wing.supplier.controller;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.wing.common.utils.JsonResult;
import com.wing.supplier.entity.request.SupplierCreateRequest;
import com.wing.supplier.entity.request.SupplierPartnerClassCreateRequest;
import com.wing.supplier.entity.response.SupplierPartnerClassResponse;
import com.wing.supplier.entity.response.SupplierQueryResponse;
import com.wing.supplier.service.SupplierService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 畅捷通-往来单位管理
 *
 * @author xiayang
 */
@Validated
@Api(value = "畅捷通-往来单位管理(供应商)", tags = "#/chanjet/supplier")
@RestController("SupplierController")
@RequestMapping("supplier/admin/supplier")
@RequiredArgsConstructor
public class SupplierController {

    @Resource
    SupplierService supplierService;

    /**
     * 查询所有供应商
     */
    @ApiOperation(value = "查询所有供应商", notes = "搜索")
    @PostMapping("/getSupplierList")
    public JsonResult<List<SupplierQueryResponse>> getSupplierList() {
        return JsonResult.success(supplierService.getSupplierList());
    }


    /**
     * 创建供应商
     * @param supplierCreateRequest
     * @return
     */
    @ApiOperation(value = "创建供应商", notes = "新增")
    @PostMapping("/createSupplier")
    public JsonResult createSupplier(@RequestBody SupplierCreateRequest supplierCreateRequest) {
       return supplierService.createSupplier(supplierCreateRequest);
    }


    /**
     * 修改供应商
     * @param supplierCreateRequest
     * @return
     */
    @ApiOperation(value = "修改供应商", notes = "修改")
    @PostMapping("/updateSupplier")
    public JsonResult updateSupplier(@RequestBody SupplierCreateRequest supplierCreateRequest) {
        return supplierService.updateSupplier(supplierCreateRequest);
    }



    /**
     * 查询所有供应商-分类
     */
    @ApiOperation(value = "查询所有供应商-分类", notes = "搜索")
    @PostMapping("/getSupplierListPartnerClass")
    public JsonResult<List<SupplierPartnerClassResponse>> getSupplierListPartnerClass() throws JsonProcessingException {
        return JsonResult.success(supplierService.getSupplierListPartnerClass());
    }


    /**
     * 创建供应商-分类
     * @param supplierPartnerClassCreateRequest
     * @return
     */
    @ApiOperation(value = "创建供应商分类", notes = "新增")
    @PostMapping("/createSupplierPartnerClass")
    public JsonResult createSupplierPartnerClass(@RequestBody SupplierPartnerClassCreateRequest supplierPartnerClassCreateRequest) {
        return supplierService.createSupplierPartnerClass(supplierPartnerClassCreateRequest);
    }




}
